package binary_tree.leetcode.medium;

/**
 * @author bruin_du
 * @description 所有大于等于节点的值之和
 * @date 2022/8/15 22:41
 **/
public class OfferII054_ConvertBST {
    TreeNode prev;
    public TreeNode convertBST(TreeNode root) {
        if (root != null) {
            convertBST(root.right);
            if (prev != null) root.val += prev.val;
            prev = root;
            convertBST(root.left);
        }
        return root;
    }
}
